<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Checks if this is the default read concern</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongodb-driver-readconcern.getlevel.html">« MongoDB\Driver\ReadConcern::getLevel</a></li>
      <li style="float: right;"><a href="mongodb-driver-readconcern.serialize.html">MongoDB\Driver\ReadConcern::serialize »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongodb-driver-readconcern.html">MongoDB\Driver\ReadConcern</a></li>
    <li>Checks if this is the default read concern</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongodb-driver-readconcern.isdefault" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\ReadConcern::isDefault</h1>
  <p class="verinfo">(mongodb &gt;=1.3.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\ReadConcern::isDefault</span> &mdash; <span class="dc-title">Checks if this is the default read concern</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-readconcern.isdefault-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\ReadConcern::isDefault</strong></span>(): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Returns whether this is the default read concern (i.e. no options are
   specified). This method is primarily intended to be used in conjunction with
   <span class="methodname"><a href="mongodb-driver-manager.getreadconcern.html" class="methodname">MongoDB\Driver\Manager::getReadConcern()</a></span> to determine
   whether the Manager has been constructed without any read concern options.
  </p>
  <p class="para">
   The driver will not include a default read concern in its read operations
   (e.g. <span class="methodname"><a href="mongodb-driver-manager.executequery.html" class="methodname">MongoDB\Driver\Manager::executeQuery()</a></span>) in order
   order to allow the server to apply its own default. Libraries that access the
   Manager&#039;s read concern to include it in their own read commands should use
   this method to ensure that default read concerns are left unset.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-readconcern.isdefault-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-readconcern.isdefault-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns <strong><code>true</code></strong> if this is the default read concern and <strong><code>false</code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-readconcern.isdefault-errors">
  <h3 class="title">错误／异常</h3>
  <ul class="simplelist">
   <li class="member">Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> on argument parsing errors.</li>
  </ul>
 </div>


 <div class="refsect1 examples" id="refsect1-mongodb-driver-readconcern.isdefault-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1336">
   <p><strong>示例 #1 <span class="function"><strong>MongoDB\Driver\ReadConcern::isDefault()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$rc&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">ReadConcern</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$rc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isDefault</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$rc&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">ReadConcern</span><span style="color: #007700">(</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">ReadConcern</span><span style="color: #007700">::</span><span style="color: #0000BB">MAJORITY</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$rc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isDefault</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$manager&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">Manager</span><span style="color: #007700">(</span><span style="color: #DD0000">'mongodb://127.0.0.1/?readConcernLevel=majority'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$manager</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getReadConcern</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$rc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isDefault</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$manager&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">Manager</span><span style="color: #007700">(</span><span style="color: #DD0000">'mongodb://127.0.0.1/'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$manager</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getReadConcern</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$rc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isDefault</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
bool(true)
bool(false)
bool(false)
bool(true)
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb-driver-readconcern.isdefault-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="mongodb-driver-manager.getreadconcern.html" class="methodname" rel="rdfs-seeAlso">MongoDB\Driver\Manager::getReadConcern()</a> - Return the ReadConcern for the Manager</span></li>
   <li class="member"><a href="https://www.mongodb.com/docs/manual/reference/read-concern/" class="link external">&raquo;&nbsp;Read Concern reference</a></li>
  </ul>
 </div>


</div></div></div></body></html>